{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}/Users/Owsiak/Dropbox/Joint Dems and Borders (with JV)/BJPS RR/Replication Files/Replication - Owsiak Vasquez - 2016 - BJPS - Cart and Horse.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}25 Jul 2016, 14:56:46

{com}. do "/var/folders/lk/7gdbhd5s7v76_gcvd9s7v2mc0000gp/T//SD12037.000000"
{txt}
{com}. *Replication data for Owsiak, Andrew P., and John A. Vasquez. 2016. The Cart and the Horse Redux: The Timing of Border Settlement and Joint Democracy. British Journal of Political Science, forthcoming.
. 
. *log using "Replication - Owsiak Vasquez - 2016 - BJPS - Cart and Horse.scml", replace
. 
. use "Owsiak Vasquez - 2016 - Cart and Horse - Replication Data.dta", replace
{txt}
{com}. drop if year>2001
{txt}(0 observations deleted)

{com}. set more off    
{txt}
{com}. 
. *TABLE 1
. *CREATE TIME PERIOD VARIABLES
. gen t1644=1 
{txt}
{com}. replace t1644=0 if year>1944
{txt}(556,990 real changes made)

{com}. 
. gen t4589=0
{txt}
{com}. replace t4589=1 if year>1944
{txt}(556,990 real changes made)

{com}. replace t4589=0 if year>1989
{txt}(203,533 real changes made)

{com}. 
. gen t9001=0
{txt}
{com}. replace t9001=1 if year>1989
{txt}(203,533 real changes made)

{com}. 
. gen t1601=1
{txt}
{com}. 
. gen t=1 if t1644==1
{txt}(556,990 missing values generated)

{com}. replace t=2 if t4589==1
{txt}(353,457 real changes made)

{com}. replace t=3 if t9001==1
{txt}(203,533 real changes made)

{com}. 
. drop if conttype!=1
{txt}(655,227 observations deleted)

{com}. 
. *FOR JTDEM AT 6+
. sort cdyad year
{txt}
{com}. by cdyad: gen runsumdem6=sum(jtdem6)
{txt}
{com}. by cdyad: gen count6=[_n]
{txt}
{com}. by cdyad: gen ratio6=runsumdem6/count6
{txt}
{com}. 
. sort cdyad t year 
{txt}
{com}. by cdyad t: gen runsumdem6t=sum(jtdem6)
{txt}
{com}. by cdyad t: gen count6t=[_n]
{txt}
{com}. by cdyad t: gen ratio6t=runsumdem6t/count6t
{txt}
{com}. 
. *Flags
. gen flag1601a=1 if t1601==1 & ratio6<1
{txt}(535 missing values generated)

{com}. gen flag1644a=1 if t1644==1 & ratio6t<1
{txt}(11,668 missing values generated)

{com}. gen flag4589a=1 if t4589==1 & ratio6t<1
{txt}(11,583 missing values generated)

{com}. gen flag9001a=1 if t9001==1 & ratio6t<1
{txt}(16,377 missing values generated)

{com}. 
. replace flag1601a=0 if flag1601a==. 
{txt}(535 real changes made)

{com}. replace flag1644a=0 if flag1644a==. & t1644==1
{txt}(84 real changes made)

{com}. replace flag4589a=0 if flag4589a==. & t4589==1
{txt}(526 real changes made)

{com}. replace flag9001a=0 if flag9001a==. & t9001==1
{txt}(690 real changes made)

{com}. 
. by cdyad: egen maxflag1601a=max(flag1601a)
{txt}
{com}. by cdyad t: egen maxflag1644a=max(flag1644a)
{txt}(11584 missing values generated)

{com}. by cdyad t: egen maxflag4589a=max(flag4589a)
{txt}(11057 missing values generated)

{com}. by cdyad t: egen maxflag9001a=max(flag9001a)
{txt}(15687 missing values generated)

{com}. 
. *Identify the dyads
. tab cdyad if t1601==1 & maxflag1601a==0

      {txt}cdyad {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2020 {c |}{res}         82       17.60       17.60
{txt}     200205 {c |}{res}         80       17.17       34.76
{txt}     210260 {c |}{res}         36        7.73       42.49
{txt}     211260 {c |}{res}         36        7.73       50.21
{txt}     225260 {c |}{res}         36        7.73       57.94
{txt}     255316 {c |}{res}          9        1.93       59.87
{txt}     260305 {c |}{res}         36        7.73       67.60
{txt}     260390 {c |}{res}         36        7.73       75.32
{txt}     290316 {c |}{res}          9        1.93       77.25
{txt}     290317 {c |}{res}          9        1.93       79.18
{txt}     305316 {c |}{res}          9        1.93       81.12
{txt}     305317 {c |}{res}          9        1.93       83.05
{txt}     305349 {c |}{res}         10        2.15       85.19
{txt}     310317 {c |}{res}          9        1.93       87.12
{txt}     310349 {c |}{res}         10        2.15       89.27
{txt}     315369 {c |}{res}          2        0.43       89.70
{txt}     316317 {c |}{res}          9        1.93       91.63
{txt}     325349 {c |}{res}         10        2.15       93.78
{txt}     343350 {c |}{res}          9        1.93       95.71
{txt}     343355 {c |}{res}          9        1.93       97.64
{txt}     565571 {c |}{res}         11        2.36      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        466      100.00
{txt}
{com}. tab cdyad if t1644==1 & maxflag1644a==0

      {txt}cdyad {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2020 {c |}{res}         25       52.08       52.08
{txt}     200205 {c |}{res}         23       47.92      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         48      100.00
{txt}
{com}. tab cdyad if t4589==1 & maxflag4589a==0

      {txt}cdyad {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2020 {c |}{res}         45        8.74        8.74
{txt}     200205 {c |}{res}         45        8.74       17.48
{txt}     210211 {c |}{res}         45        8.74       26.21
{txt}     210260 {c |}{res}         35        6.80       33.01
{txt}     211260 {c |}{res}         35        6.80       39.81
{txt}     225260 {c |}{res}         35        6.80       46.60
{txt}     225305 {c |}{res}         35        6.80       53.40
{txt}     260305 {c |}{res}         35        6.80       60.19
{txt}     260390 {c |}{res}         35        6.80       66.99
{txt}     305325 {c |}{res}         35        6.80       73.79
{txt}     375380 {c |}{res}         45        8.74       82.52
{txt}     375385 {c |}{res}         45        8.74       91.26
{txt}     380385 {c |}{res}         45        8.74      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        515      100.00
{txt}
{com}. tab cdyad if t9001==1 & maxflag9001a==0

      {txt}cdyad {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2020 {c |}{res}         12        1.84        1.84
{txt}      91092 {c |}{res}         12        1.84        3.68
{txt}      91093 {c |}{res}         11        1.68        5.36
{txt}      93094 {c |}{res}         12        1.84        7.20
{txt}      94095 {c |}{res}         12        1.84        9.04
{txt}      95100 {c |}{res}         12        1.84       10.87
{txt}     100101 {c |}{res}         12        1.84       12.71
{txt}     100130 {c |}{res}         12        1.84       14.55
{txt}     100140 {c |}{res}         12        1.84       16.39
{txt}     101140 {c |}{res}         12        1.84       18.22
{txt}     140145 {c |}{res}         12        1.84       20.06
{txt}     140160 {c |}{res}         12        1.84       21.90
{txt}     140165 {c |}{res}         12        1.84       23.74
{txt}     145155 {c |}{res}         12        1.84       25.57
{txt}     145160 {c |}{res}         12        1.84       27.41
{txt}     155160 {c |}{res}         12        1.84       29.25
{txt}     160165 {c |}{res}         12        1.84       31.09
{txt}     200205 {c |}{res}         12        1.84       32.92
{txt}     210211 {c |}{res}         12        1.84       34.76
{txt}     210255 {c |}{res}         12        1.84       36.60
{txt}     210260 {c |}{res}          1        0.15       36.75
{txt}     211220 {c |}{res}         12        1.84       38.59
{txt}     211255 {c |}{res}         12        1.84       40.43
{txt}     211260 {c |}{res}          1        0.15       40.58
{txt}     220225 {c |}{res}         12        1.84       42.42
{txt}     220230 {c |}{res}         12        1.84       44.26
{txt}     220255 {c |}{res}         12        1.84       46.09
{txt}     220260 {c |}{res}          1        0.15       46.25
{txt}     220325 {c |}{res}         12        1.84       48.09
{txt}     225255 {c |}{res}         12        1.84       49.92
{txt}     225260 {c |}{res}          1        0.15       50.08
{txt}     225305 {c |}{res}         12        1.84       51.91
{txt}     225325 {c |}{res}         12        1.84       53.75
{txt}     230235 {c |}{res}         12        1.84       55.59
{txt}     255305 {c |}{res}         12        1.84       57.43
{txt}     255315 {c |}{res}          3        0.46       57.89
{txt}     255316 {c |}{res}          9        1.38       59.26
{txt}     255390 {c |}{res}         12        1.84       61.10
{txt}     260305 {c |}{res}          1        0.15       61.26
{txt}     260315 {c |}{res}          1        0.15       61.41
{txt}     260390 {c |}{res}          1        0.15       61.56
{txt}     290316 {c |}{res}          9        1.38       62.94
{txt}     290317 {c |}{res}          9        1.38       64.32
{txt}     290368 {c |}{res}         11        1.68       66.00
{txt}     305310 {c |}{res}         12        1.84       67.84
{txt}     305315 {c |}{res}          3        0.46       68.30
{txt}     305316 {c |}{res}          9        1.38       69.68
{txt}     305317 {c |}{res}          9        1.38       71.06
{txt}     305325 {c |}{res}         12        1.84       72.89
{txt}     305349 {c |}{res}         10        1.53       74.43
{txt}     310315 {c |}{res}          3        0.46       74.89
{txt}     310317 {c |}{res}          9        1.38       76.26
{txt}     310349 {c |}{res}         10        1.53       77.79
{txt}     315369 {c |}{res}          2        0.31       78.10
{txt}     316317 {c |}{res}          9        1.38       79.48
{txt}     325349 {c |}{res}         10        1.53       81.01
{txt}     343350 {c |}{res}          9        1.38       82.39
{txt}     343355 {c |}{res}          9        1.38       83.77
{txt}     350355 {c |}{res}         12        1.84       85.60
{txt}     350640 {c |}{res}          7        1.07       86.68
{txt}     352640 {c |}{res}          6        0.92       87.60
{txt}     355640 {c |}{res}         12        1.84       89.43
{txt}     366367 {c |}{res}         11        1.68       91.12
{txt}     367368 {c |}{res}         11        1.68       92.80
{txt}     375380 {c |}{res}         12        1.84       94.64
{txt}     375385 {c |}{res}         12        1.84       96.48
{txt}     380385 {c |}{res}         12        1.84       98.32
{txt}     565571 {c |}{res}         11        1.68      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        653      100.00
{txt}
{com}. 
. *Mark first instance of joint democracy
. by cdyad: gen firstdem6=1 if runsumdem6==1 & count6==1
{txt}(19,130 missing values generated)

{com}. by cdyad: replace firstdem6=1 if runsumdem6==1 & runsumdem6[_n-1]==0
{txt}(95 real changes made)

{com}. by cdyad: replace firstdem6=0 if firstdem6==.
{txt}(19,035 real changes made)

{com}. 
. *Identify dyads with years - +6
. list cdyad year bordersettleyear if t1601==1 & maxflag1601a==0 & firstdem6==1
{txt}
       {c TLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c TRC}
       {c |} {res} cdyad   year   border~r {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
    1. {c |} {res}  2020   1920       1908 {txt}{c |}
 4080. {c |} {res}200205   1922       1999 {txt}{c |}
 4502. {c |} {res}210260   1955       1824 {txt}{c |}
 4901. {c |} {res}211260   1955       1816 {txt}{c |}
 6043. {c |} {res}225260   1955       1854 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 7611. {c |} {res}255316   1993       1919 {txt}{c |}
 7874. {c |} {res}260305   1955       1816 {txt}{c |}
 7946. {c |} {res}260390   1955       1919 {txt}{c |}
 8335. {c |} {res}290316   1993       1923 {txt}{c |}
 8344. {c |} {res}290317   1993       1923 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9098. {c |} {res}305316   1993       1919 {txt}{c |}
 9107. {c |} {res}305317   1993       1920 {txt}{c |}
 9241. {c |} {res}305349   1992       1920 {txt}{c |}
 9321. {c |} {res}310317   1993       1920 {txt}{c |}
 9417. {c |} {res}310349   1992       1920 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9638. {c |} {res}315369   1991       1946 {txt}{c |}
 9640. {c |} {res}316317   1993       1994 {txt}{c |}
 9769. {c |} {res}325349   1992       1975 {txt}{c |}
10098. {c |} {res}343350   1993       1912 {txt}{c |}
10107. {c |} {res}343355   1993       1919 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
15867. {c |} {res}565571   1990       1990 {txt}{c |}
       {c BLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c BRC}

{com}. list cdyad year bordersettleyear if t1644==1 & maxflag1644a==0 & firstdem6==1
{txt}
       {c TLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c TRC}
       {c |} {res} cdyad   year   border~r {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
    1. {c |} {res}  2020   1920       1908 {txt}{c |}
 4080. {c |} {res}200205   1922       1999 {txt}{c |}
       {c BLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c BRC}

{com}. list cdyad year bordersettleyear if t4589==1 & maxflag4589a==0 & firstdem6==1
{txt}
       {c TLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c TRC}
       {c |} {res} cdyad   year   border~r {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 4502. {c |} {res}210260   1955       1824 {txt}{c |}
 4901. {c |} {res}211260   1955       1816 {txt}{c |}
 6043. {c |} {res}225260   1955       1854 {txt}{c |}
 7874. {c |} {res}260305   1955       1816 {txt}{c |}
 7946. {c |} {res}260390   1955       1919 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9136. {c |} {res}305325   1955       1919 {txt}{c |}
       {c BLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c BRC}

{com}. list cdyad year bordersettleyear if t9001==1 & maxflag9001a==0 & firstdem6==1
{txt}
       {c TLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c TRC}
       {c |} {res} cdyad   year   border~r {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
  918. {c |} {res} 91093   1990       1960 {txt}{c |}
  996. {c |} {res} 93094   1990       1858 {txt}{c |}
 7611. {c |} {res}255316   1993       1919 {txt}{c |}
 7945. {c |} {res}260315   1990       1919 {txt}{c |}
 8335. {c |} {res}290316   1993       1923 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 8344. {c |} {res}290317   1993       1923 {txt}{c |}
 8497. {c |} {res}290368   1991       1938 {txt}{c |}
 9028. {c |} {res}305310   1990       1921 {txt}{c |}
 9098. {c |} {res}305316   1993       1919 {txt}{c |}
 9107. {c |} {res}305317   1993       1920 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9241. {c |} {res}305349   1992       1920 {txt}{c |}
 9318. {c |} {res}310315   1990       1920 {txt}{c |}
 9321. {c |} {res}310317   1993       1920 {txt}{c |}
 9417. {c |} {res}310349   1992       1920 {txt}{c |}
 9638. {c |} {res}315369   1991       1946 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9640. {c |} {res}316317   1993       1994 {txt}{c |}
 9769. {c |} {res}325349   1992       1975 {txt}{c |}
10098. {c |} {res}343350   1993       1912 {txt}{c |}
10107. {c |} {res}343355   1993       1919 {txt}{c |}
10546. {c |} {res}350355   1990       1913 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
10900. {c |} {res}355640   1990       1913 {txt}{c |}
12153. {c |} {res}367368   1991          . {txt}{c |}
15867. {c |} {res}565571   1990       1990 {txt}{c |}
       {c BLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c BRC}

{com}. 
. *FOR JTDEM AT 5+
. gen jtdem5=0
{txt}
{com}. replace jtdem5=1 if dem1>4 & dem1!=. & dem2>4 & dem2!=.
{txt}(2,496 real changes made)

{com}. 
. sort cdyad year
{txt}
{com}. by cdyad: gen runsumdem5=sum(jtdem5)
{txt}
{com}. by cdyad: gen count5=[_n]
{txt}
{com}. by cdyad: gen ratio5=runsumdem5/count5
{txt}
{com}. 
. sort cdyad t year 
{txt}
{com}. by cdyad t: gen runsumdem5t=sum(jtdem5)
{txt}
{com}. by cdyad t: gen count5t=[_n]
{txt}
{com}. by cdyad t: gen ratio5t=runsumdem5t/count5t
{txt}
{com}. 
. *Flags
. gen flag1601b=1 if t1601==1 & ratio5<1
{txt}(649 missing values generated)

{com}. gen flag1644b=1 if t1644==1 & ratio5t<1
{txt}(11,668 missing values generated)

{com}. gen flag4589b=1 if t4589==1 & ratio5t<1
{txt}(11,619 missing values generated)

{com}. gen flag9001b=1 if t9001==1 & ratio5t<1
{txt}(16,517 missing values generated)

{com}. 
. replace flag1601b=0 if flag1601b==. 
{txt}(649 real changes made)

{com}. replace flag1644b=0 if flag1644b==. & t1644==1
{txt}(84 real changes made)

{com}. replace flag4589b=0 if flag4589b==. & t4589==1
{txt}(562 real changes made)

{com}. replace flag9001b=0 if flag9001b==. & t9001==1
{txt}(830 real changes made)

{com}. 
. by cdyad: egen maxflag1601b=max(flag1601b)
{txt}
{com}. by cdyad t: egen maxflag1644b=max(flag1644b)
{txt}(11584 missing values generated)

{com}. by cdyad t: egen maxflag4589b=max(flag4589b)
{txt}(11057 missing values generated)

{com}. by cdyad t: egen maxflag9001b=max(flag9001b)
{txt}(15687 missing values generated)

{com}. 
. *Identify the dyads
. tab cdyad if t1601==1 & maxflag1601b==0

      {txt}cdyad {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2020 {c |}{res}         82       14.19       14.19
{txt}     200205 {c |}{res}         80       13.84       28.03
{txt}     210260 {c |}{res}         36        6.23       34.26
{txt}     211260 {c |}{res}         36        6.23       40.48
{txt}     220260 {c |}{res}         36        6.23       46.71
{txt}     225260 {c |}{res}         36        6.23       52.94
{txt}     255316 {c |}{res}          9        1.56       54.50
{txt}     260305 {c |}{res}         36        6.23       60.73
{txt}     260390 {c |}{res}         36        6.23       66.96
{txt}     290316 {c |}{res}          9        1.56       68.51
{txt}     290317 {c |}{res}          9        1.56       70.07
{txt}     290369 {c |}{res}         11        1.90       71.97
{txt}     305316 {c |}{res}          9        1.56       73.53
{txt}     305317 {c |}{res}          9        1.56       75.09
{txt}     305349 {c |}{res}         10        1.73       76.82
{txt}     310317 {c |}{res}          9        1.56       78.37
{txt}     310349 {c |}{res}         10        1.73       80.10
{txt}     310369 {c |}{res}         11        1.90       82.01
{txt}     315369 {c |}{res}          2        0.35       82.35
{txt}     316317 {c |}{res}          9        1.56       83.91
{txt}     317369 {c |}{res}          9        1.56       85.47
{txt}     325349 {c |}{res}         10        1.73       87.20
{txt}     343350 {c |}{res}          9        1.56       88.75
{txt}     343355 {c |}{res}          9        1.56       90.31
{txt}     359360 {c |}{res}         11        1.90       92.21
{txt}     359369 {c |}{res}         11        1.90       94.12
{txt}     360369 {c |}{res}         11        1.90       96.02
{txt}     560565 {c |}{res}         12        2.08       98.10
{txt}     565571 {c |}{res}         11        1.90      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        578      100.00
{txt}
{com}. tab cdyad if t1644==1 & maxflag1644b==0

      {txt}cdyad {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2020 {c |}{res}         25       52.08       52.08
{txt}     200205 {c |}{res}         23       47.92      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}         48      100.00
{txt}
{com}. tab cdyad if t4589==1 & maxflag4589b==0

      {txt}cdyad {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2020 {c |}{res}         45        8.18        8.18
{txt}     200205 {c |}{res}         45        8.18       16.36
{txt}     210211 {c |}{res}         45        8.18       24.55
{txt}     210260 {c |}{res}         35        6.36       30.91
{txt}     211260 {c |}{res}         35        6.36       37.27
{txt}     220260 {c |}{res}         35        6.36       43.64
{txt}     225260 {c |}{res}         35        6.36       50.00
{txt}     225305 {c |}{res}         35        6.36       56.36
{txt}     260305 {c |}{res}         35        6.36       62.73
{txt}     260390 {c |}{res}         35        6.36       69.09
{txt}     305325 {c |}{res}         35        6.36       75.45
{txt}     375380 {c |}{res}         45        8.18       83.64
{txt}     375385 {c |}{res}         45        8.18       91.82
{txt}     380385 {c |}{res}         45        8.18      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        550      100.00
{txt}
{com}. tab cdyad if t9001==1 & maxflag9001b==0

      {txt}cdyad {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
       2020 {c |}{res}         12        1.52        1.52
{txt}      91092 {c |}{res}         12        1.52        3.03
{txt}      91093 {c |}{res}         11        1.39        4.42
{txt}      93094 {c |}{res}         12        1.52        5.93
{txt}      94095 {c |}{res}         12        1.52        7.45
{txt}      95100 {c |}{res}         12        1.52        8.96
{txt}     100101 {c |}{res}         12        1.52       10.48
{txt}     100130 {c |}{res}         12        1.52       11.99
{txt}     100140 {c |}{res}         12        1.52       13.51
{txt}     101140 {c |}{res}         12        1.52       15.03
{txt}     140145 {c |}{res}         12        1.52       16.54
{txt}     140160 {c |}{res}         12        1.52       18.06
{txt}     140165 {c |}{res}         12        1.52       19.57
{txt}     145155 {c |}{res}         12        1.52       21.09
{txt}     145160 {c |}{res}         12        1.52       22.60
{txt}     155160 {c |}{res}         12        1.52       24.12
{txt}     160165 {c |}{res}         12        1.52       25.63
{txt}     200205 {c |}{res}         12        1.52       27.15
{txt}     210211 {c |}{res}         12        1.52       28.66
{txt}     210255 {c |}{res}         12        1.52       30.18
{txt}     210260 {c |}{res}          1        0.13       30.30
{txt}     211220 {c |}{res}         12        1.52       31.82
{txt}     211255 {c |}{res}         12        1.52       33.33
{txt}     211260 {c |}{res}          1        0.13       33.46
{txt}     220225 {c |}{res}         12        1.52       34.97
{txt}     220230 {c |}{res}         12        1.52       36.49
{txt}     220255 {c |}{res}         12        1.52       38.01
{txt}     220260 {c |}{res}          1        0.13       38.13
{txt}     220325 {c |}{res}         12        1.52       39.65
{txt}     225255 {c |}{res}         12        1.52       41.16
{txt}     225260 {c |}{res}          1        0.13       41.29
{txt}     225305 {c |}{res}         12        1.52       42.80
{txt}     225325 {c |}{res}         12        1.52       44.32
{txt}     230235 {c |}{res}         12        1.52       45.83
{txt}     255290 {c |}{res}         12        1.52       47.35
{txt}     255305 {c |}{res}         12        1.52       48.86
{txt}     255315 {c |}{res}          3        0.38       49.24
{txt}     255316 {c |}{res}          9        1.14       50.38
{txt}     255390 {c |}{res}         12        1.52       51.89
{txt}     260305 {c |}{res}          1        0.13       52.02
{txt}     260315 {c |}{res}          1        0.13       52.15
{txt}     260390 {c |}{res}          1        0.13       52.27
{txt}     290315 {c |}{res}          3        0.38       52.65
{txt}     290316 {c |}{res}          9        1.14       53.79
{txt}     290317 {c |}{res}          9        1.14       54.92
{txt}     290368 {c |}{res}         11        1.39       56.31
{txt}     290369 {c |}{res}         11        1.39       57.70
{txt}     305310 {c |}{res}         12        1.52       59.22
{txt}     305315 {c |}{res}          3        0.38       59.60
{txt}     305316 {c |}{res}          9        1.14       60.73
{txt}     305317 {c |}{res}          9        1.14       61.87
{txt}     305325 {c |}{res}         12        1.52       63.38
{txt}     305349 {c |}{res}         10        1.26       64.65
{txt}     310315 {c |}{res}          3        0.38       65.03
{txt}     310317 {c |}{res}          9        1.14       66.16
{txt}     310349 {c |}{res}         10        1.26       67.42
{txt}     310360 {c |}{res}         12        1.52       68.94
{txt}     310369 {c |}{res}         11        1.39       70.33
{txt}     315369 {c |}{res}          2        0.25       70.58
{txt}     316317 {c |}{res}          9        1.14       71.72
{txt}     317369 {c |}{res}          9        1.14       72.85
{txt}     325349 {c |}{res}         10        1.26       74.12
{txt}     343350 {c |}{res}          9        1.14       75.25
{txt}     343355 {c |}{res}          9        1.14       76.39
{txt}     350355 {c |}{res}         12        1.52       77.90
{txt}     350640 {c |}{res}          7        0.88       78.79
{txt}     352640 {c |}{res}          6        0.76       79.55
{txt}     355360 {c |}{res}         12        1.52       81.06
{txt}     355640 {c |}{res}         12        1.52       82.58
{txt}     359360 {c |}{res}         11        1.39       83.96
{txt}     359369 {c |}{res}         11        1.39       85.35
{txt}     360369 {c |}{res}         11        1.39       86.74
{txt}     366367 {c |}{res}         11        1.39       88.13
{txt}     367368 {c |}{res}         11        1.39       89.52
{txt}     375380 {c |}{res}         12        1.52       91.04
{txt}     375385 {c |}{res}         12        1.52       92.55
{txt}     380385 {c |}{res}         12        1.52       94.07
{txt}     560565 {c |}{res}         12        1.52       95.58
{txt}     560571 {c |}{res}         12        1.52       97.10
{txt}     565571 {c |}{res}         11        1.39       98.48
{txt}     750790 {c |}{res}         12        1.52      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        792      100.00
{txt}
{com}. 
. *Mark first instance of joint democracy
. by cdyad: gen firstdem5=1 if runsumdem5==1 & count5==1
{txt}(19,122 missing values generated)

{com}. by cdyad: replace firstdem5=1 if runsumdem5==1 & runsumdem5[_n-1]==0 & count5!=1
{txt}(96 real changes made)

{com}. by cdyad: replace firstdem5=0 if firstdem5==.
{txt}(19,026 real changes made)

{com}. 
. *Identify dyads wih years +5
. list cdyad year bordersettleyear if t1601==1 & maxflag1601b==0 & firstdem5==1
{txt}
       {c TLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c TRC}
       {c |} {res} cdyad   year   border~r {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
    1. {c |} {res}  2020   1920       1908 {txt}{c |}
 4080. {c |} {res}200205   1922       1999 {txt}{c |}
 4502. {c |} {res}210260   1955       1824 {txt}{c |}
 4901. {c |} {res}211260   1955       1816 {txt}{c |}
 5658. {c |} {res}220260   1955       1945 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 6043. {c |} {res}225260   1955       1854 {txt}{c |}
 7611. {c |} {res}255316   1993       1919 {txt}{c |}
 7874. {c |} {res}260305   1955       1816 {txt}{c |}
 7946. {c |} {res}260390   1955       1919 {txt}{c |}
 8335. {c |} {res}290316   1993       1923 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 8344. {c |} {res}290317   1993       1923 {txt}{c |}
 8508. {c |} {res}290369   1991       1921 {txt}{c |}
 9098. {c |} {res}305316   1993       1919 {txt}{c |}
 9107. {c |} {res}305317   1993       1920 {txt}{c |}
 9241. {c |} {res}305349   1992       1920 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9321. {c |} {res}310317   1993       1920 {txt}{c |}
 9417. {c |} {res}310349   1992       1920 {txt}{c |}
 9558. {c |} {res}310369   1991       1947 {txt}{c |}
 9638. {c |} {res}315369   1991       1946 {txt}{c |}
 9640. {c |} {res}316317   1993       1994 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9649. {c |} {res}317369   1993       1946 {txt}{c |}
 9769. {c |} {res}325349   1992       1975 {txt}{c |}
10098. {c |} {res}343350   1993       1912 {txt}{c |}
10107. {c |} {res}343355   1993       1919 {txt}{c |}
10912. {c |} {res}359360   1991       1878 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
10923. {c |} {res}359369   1991          . {txt}{c |}
11043. {c |} {res}360369   1991       1940 {txt}{c |}
15750. {c |} {res}560565   1990       1993 {txt}{c |}
15867. {c |} {res}565571   1990       1990 {txt}{c |}
       {c BLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c BRC}

{com}. list cdyad year bordersettleyear if t1644==1 & maxflag1644b==0 & firstdem5==1
{txt}
       {c TLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c TRC}
       {c |} {res} cdyad   year   border~r {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
    1. {c |} {res}  2020   1920       1908 {txt}{c |}
 4080. {c |} {res}200205   1922       1999 {txt}{c |}
       {c BLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c BRC}

{com}. list cdyad year bordersettleyear if t4589==1 & maxflag4589b==0 & firstdem5==1
{txt}
       {c TLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c TRC}
       {c |} {res} cdyad   year   border~r {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 4502. {c |} {res}210260   1955       1824 {txt}{c |}
 4901. {c |} {res}211260   1955       1816 {txt}{c |}
 5658. {c |} {res}220260   1955       1945 {txt}{c |}
 6043. {c |} {res}225260   1955       1854 {txt}{c |}
 7874. {c |} {res}260305   1955       1816 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 7946. {c |} {res}260390   1955       1919 {txt}{c |}
 9136. {c |} {res}305325   1955       1919 {txt}{c |}
       {c BLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c BRC}

{com}. list cdyad year bordersettleyear if t9001==1 & maxflag9001b==0 & firstdem5==1
{txt}
       {c TLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c TRC}
       {c |} {res} cdyad   year   border~r {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
  918. {c |} {res} 91093   1990       1960 {txt}{c |}
  996. {c |} {res} 93094   1990       1858 {txt}{c |}
 7611. {c |} {res}255316   1993       1919 {txt}{c |}
 7945. {c |} {res}260315   1990       1919 {txt}{c |}
 8335. {c |} {res}290316   1993       1923 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 8344. {c |} {res}290317   1993       1923 {txt}{c |}
 8497. {c |} {res}290368   1991       1938 {txt}{c |}
 8508. {c |} {res}290369   1991       1921 {txt}{c |}
 9028. {c |} {res}305310   1990       1921 {txt}{c |}
 9098. {c |} {res}305316   1993       1919 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9107. {c |} {res}305317   1993       1920 {txt}{c |}
 9241. {c |} {res}305349   1992       1920 {txt}{c |}
 9318. {c |} {res}310315   1990       1920 {txt}{c |}
 9321. {c |} {res}310317   1993       1920 {txt}{c |}
 9417. {c |} {res}310349   1992       1920 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9497. {c |} {res}310360   1990       1920 {txt}{c |}
 9558. {c |} {res}310369   1991       1947 {txt}{c |}
 9638. {c |} {res}315369   1991       1946 {txt}{c |}
 9640. {c |} {res}316317   1993       1994 {txt}{c |}
 9649. {c |} {res}317369   1993       1946 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
 9769. {c |} {res}325349   1992       1975 {txt}{c |}
10098. {c |} {res}343350   1993       1912 {txt}{c |}
10107. {c |} {res}343355   1993       1919 {txt}{c |}
10546. {c |} {res}350355   1990       1913 {txt}{c |}
10809. {c |} {res}355360   1990       1878 {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
10900. {c |} {res}355640   1990       1913 {txt}{c |}
10912. {c |} {res}359360   1991       1878 {txt}{c |}
10923. {c |} {res}359369   1991          . {txt}{c |}
11043. {c |} {res}360369   1991       1940 {txt}{c |}
12153. {c |} {res}367368   1991          . {txt}{c |}
       {c LT}{hline 8}{c -}{hline 6}{c -}{hline 10}{c RT}
15750. {c |} {res}560565   1990       1993 {txt}{c |}
15821. {c |} {res}560571   1990       1884 {txt}{c |}
15867. {c |} {res}565571   1990       1990 {txt}{c |}
18572. {c |} {res}750790   1990       1875 {txt}{c |}
       {c BLC}{hline 8}{c -}{hline 6}{c -}{hline 10}{c BRC}

{com}. 
. 
. *TABLE 2
. gen nondem6=1 if jtdem6==0 & jtdem6!=.
{txt}(2,286 missing values generated)

{com}. replace nondem6=0 if jtdem6==1 & jtdem6!=.
{txt}(2,286 real changes made)

{com}. 
. sort cdyad year
{txt}
{com}. by cdyad: gen runsumnondem6=sum(nondem6)
{txt}
{com}. by cdyad: egen maxdem6=max(runsumdem6)
{txt}
{com}. by cdyad: egen maxnondem6=max(runsumnondem6)
{txt}
{com}. 
. sort settlem cdyad year
{txt}
{com}. by settlem cdyad: gen setcountdem6=sum(jtdem6)
{txt}
{com}. by settlem cdyad: gen setcountnon6=sum(nondem6)
{txt}
{com}. by settlem cdyad: egen maxsetdem6=max(setcountdem6)
{txt}
{com}. by settlem cdyad: egen maxsetnon6=max(setcountnon6)
{txt}
{com}. by settlem cdyad: gen countersetdyad=_n
{txt}
{com}. 
. gen dem6byset=maxsetdem6 if countersetdyad==1
{txt}(18,654 missing values generated)

{com}. gen non6byset=maxsetnon6 if countersetdyad==1
{txt}(18,654 missing values generated)

{com}. 
. ttest dem6byset, by (settlem)

{txt}Two-sample t test with equal variances
{hline 9}{c TT}{hline 68}
   Group{col 10}{c |}{col 16}Obs{col 27}Mean{col 35}Std. Err.{col 47}Std. Dev.{col 59}[95% Conf. Interval]
{hline 9}{c +}{hline 68}
       0 {c |}{res}{col 12}    137{col 22} 1.211679{col 34} .6032713{col 46}  7.06111{col 58} .0186731{col 70} 2.404685
       {txt}1 {c |}{res}{col 12}    288{col 22} 7.107639{col 34} .9602891{col 46} 16.29665{col 58} 5.217536{col 70} 8.997742
{txt}{hline 9}{c +}{hline 68}
combined {c |}{res}{col 12}    425{col 22} 5.207059{col 34} .6917533{col 46} 14.26086{col 58} 3.847366{col 70} 6.566752
{txt}{hline 9}{c +}{hline 68}
    diff {c |}{res}{col 22} -5.89596{col 34} 1.453829{col 58}-8.753589{col 70}-3.038331
{txt}{hline 9}{c BT}{hline 68}
    diff = mean({res}0{txt}) - mean({res}1{txt})                                      t = {res} -4.0555
{txt}Ho: diff = 0                                     degrees of freedom = {res}     423

    {txt}Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = {res}0.0000         {txt}Pr(|T| > |t|) = {res}0.0001          {txt}Pr(T > t) = {res}1.0000
{txt}
{com}. ttest non6byset, by (settlem)

{txt}Two-sample t test with equal variances
{hline 9}{c TT}{hline 68}
   Group{col 10}{c |}{col 16}Obs{col 27}Mean{col 35}Std. Err.{col 47}Std. Dev.{col 59}[95% Conf. Interval]
{hline 9}{c +}{hline 68}
       0 {c |}{res}{col 12}    137{col 22} 24.76642{col 34}  2.36554{col 46} 27.68793{col 58} 20.08843{col 70} 29.44442
       {txt}1 {c |}{res}{col 12}    288{col 22} 39.02431{col 34} 1.728348{col 46} 29.33103{col 58} 35.62246{col 70} 42.42615
{txt}{hline 9}{c +}{hline 68}
combined {c |}{res}{col 12}    425{col 22} 34.42824{col 34} 1.433006{col 46} 29.54219{col 58} 31.61155{col 70} 37.24492
{txt}{hline 9}{c +}{hline 68}
    diff {c |}{res}{col 22}-14.25788{col 34} 2.990378{col 58}-20.13573{col 70}-8.380031
{txt}{hline 9}{c BT}{hline 68}
    diff = mean({res}0{txt}) - mean({res}1{txt})                                      t = {res} -4.7679
{txt}Ho: diff = 0                                     degrees of freedom = {res}     423

    {txt}Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = {res}0.0000         {txt}Pr(|T| > |t|) = {res}0.0000          {txt}Pr(T > t) = {res}1.0000
{txt}
{com}. 
. 
. *At 5 level
. gen nondem5=1 if jtdem5==0 & jtdem5!=.
{txt}(2,496 missing values generated)

{com}. replace nondem5=0 if jtdem5==1 & jtdem5!=.
{txt}(2,496 real changes made)

{com}. 
. sort cdyad year
{txt}
{com}. by cdyad: gen runsumnondem5=sum(nondem5)
{txt}
{com}. by cdyad: egen maxdem5=max(runsumdem5)
{txt}
{com}. by cdyad: egen maxnondem5=max(runsumnondem5)
{txt}
{com}. 
. sort settlem cdyad year
{txt}
{com}. by settlem cdyad: gen setcountdem5=sum(jtdem5)
{txt}
{com}. by settlem cdyad: gen setcountnon5=sum(nondem5)
{txt}
{com}. by settlem cdyad: egen maxsetdem5=max(setcountdem5)
{txt}
{com}. by settlem cdyad: egen maxsetnon5=max(setcountnon5)
{txt}
{com}. *by settlem cdyad: gen countersetdyad=_n
. 
. gen dem5byset=maxsetdem5 if countersetdyad==1
{txt}(18,654 missing values generated)

{com}. gen non5byset=maxsetnon5 if countersetdyad==1
{txt}(18,654 missing values generated)

{com}. 
. ttest dem5byset, by (settlem)

{txt}Two-sample t test with equal variances
{hline 9}{c TT}{hline 68}
   Group{col 10}{c |}{col 16}Obs{col 27}Mean{col 35}Std. Err.{col 47}Std. Dev.{col 59}[95% Conf. Interval]
{hline 9}{c +}{hline 68}
       0 {c |}{res}{col 12}    137{col 22} 1.262774{col 34} .6055658{col 46} 7.087966{col 58} .0652305{col 70} 2.460317
       {txt}1 {c |}{res}{col 12}    288{col 22} 7.784722{col 34} 1.011492{col 46} 17.16559{col 58} 5.793839{col 70} 9.775605
{txt}{hline 9}{c +}{hline 68}
combined {c |}{res}{col 12}    425{col 22} 5.682353{col 34}  .727409{col 46} 14.99592{col 58} 4.252576{col 70}  7.11213
{txt}{hline 9}{c +}{hline 68}
    diff {c |}{res}{col 22}-6.521948{col 34} 1.525594{col 58}-9.520637{col 70} -3.52326
{txt}{hline 9}{c BT}{hline 68}
    diff = mean({res}0{txt}) - mean({res}1{txt})                                      t = {res} -4.2750
{txt}Ho: diff = 0                                     degrees of freedom = {res}     423

    {txt}Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = {res}0.0000         {txt}Pr(|T| > |t|) = {res}0.0000          {txt}Pr(T > t) = {res}1.0000
{txt}
{com}. ttest non5byset, by (settlem)

{txt}Two-sample t test with equal variances
{hline 9}{c TT}{hline 68}
   Group{col 10}{c |}{col 16}Obs{col 27}Mean{col 35}Std. Err.{col 47}Std. Dev.{col 59}[95% Conf. Interval]
{hline 9}{c +}{hline 68}
       0 {c |}{res}{col 12}    137{col 22} 24.71533{col 34}  2.36099{col 46} 27.63468{col 58} 20.04633{col 70} 29.38433
       {txt}1 {c |}{res}{col 12}    288{col 22} 38.34722{col 34} 1.706703{col 46} 28.96371{col 58} 34.98798{col 70} 41.70646
{txt}{hline 9}{c +}{hline 68}
combined {c |}{res}{col 12}    425{col 22} 33.95294{col 34} 1.417105{col 46} 29.21436{col 58} 31.16752{col 70} 36.73837
{txt}{hline 9}{c +}{hline 68}
    diff {c |}{res}{col 22}-13.63189{col 34} 2.962375{col 58} -19.4547{col 70}-7.809086
{txt}{hline 9}{c BT}{hline 68}
    diff = mean({res}0{txt}) - mean({res}1{txt})                                      t = {res} -4.6017
{txt}Ho: diff = 0                                     degrees of freedom = {res}     423

    {txt}Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = {res}0.0000         {txt}Pr(|T| > |t|) = {res}0.0000          {txt}Pr(T > t) = {res}1.0000
{txt}
{com}. 
. *TABLE 3
. gen demyear6=year if firstdem6==1
{txt}(19,035 missing values generated)

{com}. gen difference=demyear6-bordersettleyear
{txt}(19,052 missing values generated)

{com}. summ difference, detail

                         {txt}difference
{hline 61}
      Percentiles      Smallest
 1%    {res}       -8            -77
{txt} 5%    {res}       -2             -8
{txt}10%    {res}        0             -6       {txt}Obs         {res}        112
{txt}25%    {res}       35             -5       {txt}Sum of Wgt. {res}        112

{txt}50%    {res}       70                      {txt}Mean          {res} 71.41071
                        {txt}Largest       Std. Dev.     {res}   62.277
{txt}75%    {res}     93.5            241
{txt}90%    {res}      131            254       {txt}Variance      {res} 3878.424
{txt}95%    {res}      144            265       {txt}Skewness      {res} 2.199626
{txt}99%    {res}      265            432       {txt}Kurtosis      {res} 12.97229
{txt}
{com}. 
. *At Polity5
. gen demyear5=year if firstdem5==1
{txt}(19,026 missing values generated)

{com}. gen difference5=demyear5-bordersettleyear
{txt}(19,045 missing values generated)

{com}. summ difference5, detail

                         {txt}difference5
{hline 61}
      Percentiles      Smallest
 1%    {res}       -8            -77
{txt} 5%    {res}       -3             -8
{txt}10%    {res}        0             -6       {txt}Obs         {res}        119
{txt}25%    {res}       34             -5       {txt}Sum of Wgt. {res}        119

{txt}50%    {res}       70                      {txt}Mean          {res} 69.66387
                        {txt}Largest       Std. Dev.     {res} 60.54208
{txt}75%    {res}       92            231
{txt}90%    {res}      121            253       {txt}Variance      {res} 3665.344
{txt}95%    {res}      144            265       {txt}Skewness      {res} 2.255172
{txt}99%    {res}      265            431       {txt}Kurtosis      {res} 13.67392
{txt}
{com}. 
. 
. *TABLE 4
. 
. use "Owsiak Vasquez - 2016 - Cart and Horse - Replication Data.dta", clear
{txt}
{com}. 
. drop if conttype==1
{txt}(19,164 observations deleted)

{com}. drop if year<1919
{txt}(63,492 observations deleted)

{com}. sort cdyad year
{txt}
{com}. by cdyad: gen obs=_n
{txt}
{com}. 
. *Mark first instance of joint democracy
. by cdyad: gen runsumdem6=sum(jtdem6)
{txt}
{com}. by cdyad: gen count6=[_n]
{txt}
{com}. by cdyad: gen firstdem6=1 if runsumdem6==1 & count6==1
{txt}(590,357 missing values generated)

{com}. by cdyad: replace firstdem6=1 if runsumdem6==1 & runsumdem6[_n-1]==0
{txt}(3,084 real changes made)

{com}. by cdyad: replace firstdem6=0 if firstdem6==.
{txt}(587,273 real changes made)

{com}. 
. by cdyad: gen sumfirstdem = sum(firstdem6)
{txt}
{com}. by cdyad: gen sumbothallset=sum(bothallsettle)
{txt}
{com}. 
. gen diffdemset = sumfirstdem-sumbothallset
{txt}
{com}. 
. gen violation=1 if firstdem==1 & sumbothallset==0
{txt}(589,093 missing values generated)

{com}. replace violation=0 if violation==. & sumbothallset!=.
{txt}(589,093 real changes made)

{com}. by cdyad: egen maxviolation=max(violation)
{txt}
{com}. 
. tab maxviolation if conttype!=1 & conttype!=.

{txt}maxviolatio {c |}
          n {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}    491,015       82.98       82.98
{txt}          1 {c |}{res}    100,720       17.02      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}    591,735      100.00
{txt}
{com}. tab maxviolation if obs==1 & conttype!=1 & conttype!=.

{txt}maxviolatio {c |}
          n {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     16,294       86.05       86.05
{txt}          1 {c |}{res}      2,642       13.95      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     18,936      100.00
{txt}
{com}. 
. gen simuldyad=1 if sumbothallset==1 & firstdem==1
{txt}(591,346 missing values generated)

{com}. replace simuldyad=0 if simuldyad==. & sumbothallset!=.
{txt}(591,346 real changes made)

{com}. by cdyad: egen maxsimul=max(simuldyad)
{txt}
{com}. 
. tab maxsimul if conttype!=1 & conttype!=.

   {txt}maxsimul {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}    576,288       97.39       97.39
{txt}          1 {c |}{res}     15,447        2.61      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}    591,735      100.00
{txt}
{com}. tab maxsimul if obs==1 & conttype!=1 & conttype!=.

   {txt}maxsimul {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     18,547       97.95       97.95
{txt}          1 {c |}{res}        389        2.05      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     18,936      100.00
{txt}
{com}. 
. by cdyad: egen maxsumfirstdem=max(sumfirstdem)
{txt}
{com}. by cdyad: egen maxsumbothallset=max(sumbothallset)
{txt}
{com}. by cdyad: gen neither=1 if maxsumfirstdem==0 & maxsumbothallset==0
{txt}(360,352 missing values generated)

{com}. by cdyad: replace neither=0 if neither==. & sumbothallset!=.
{txt}(360,352 real changes made)

{com}. 
. tab neither if conttype!=1 & conttype!=.

    {txt}neither {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}    360,352       60.90       60.90
{txt}          1 {c |}{res}    231,383       39.10      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}    591,735      100.00
{txt}
{com}. tab neither if obs==1 & conttype!=1 & conttype!=.

    {txt}neither {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}      8,697       45.93       45.93
{txt}          1 {c |}{res}     10,239       54.07      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     18,936      100.00
{txt}
{com}. 
. gen settlefirst=1 if neither==0 & maxviolation==0 & maxsimul==0
{txt}(347,550 missing values generated)

{com}. replace settlefirst=0 if settlefirst==. & sumbothallset!=.
{txt}(347,550 real changes made)

{com}. 
. tab settlefirst if conttype!=1 & conttype!=.

{txt}settlefirst {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}    347,550       58.73       58.73
{txt}          1 {c |}{res}    244,185       41.27      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}    591,735      100.00
{txt}
{com}. tab settlefirst if obs==1 & conttype!=1 & conttype!=.

{txt}settlefirst {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     13,270       70.08       70.08
{txt}          1 {c |}{res}      5,666       29.92      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     18,936      100.00
{txt}
{com}. 
. *For table: use only settlefirst and violation (which is joint dem first)
. *Dyad= 5666/(5666+2642)=68.20
. *Dyad-year= 244185/(244185+100720)=70.80%
. 
. *With polity at 5
. drop firstdem6 sumfirstdem diffdemset violation maxviolation simuldyad maxsimul maxsumfirstdem maxsumbothallset sumbothallset
{txt}
{com}. drop neither settlefirst
{txt}
{com}. 
. gen jtdem5=0
{txt}
{com}. replace jtdem5=1 if dem1>4 & dem1!=. & dem2>4 & dem2!=.
{txt}(69,858 real changes made)

{com}. 
. by cdyad: gen runsumdem5=sum(jtdem5)
{txt}
{com}. by cdyad: gen count5=[_n]
{txt}
{com}. by cdyad: gen firstdem5=1 if runsumdem5==1 & count5==1
{txt}(590,146 missing values generated)

{com}. by cdyad: replace firstdem5=1 if runsumdem5==1 & runsumdem5[_n-1]==0
{txt}(3,525 real changes made)

{com}. by cdyad: replace firstdem5=0 if firstdem5==.
{txt}(586,621 real changes made)

{com}. 
. by cdyad: gen sumfirstdem=sum(firstdem5)
{txt}
{com}. by cdyad: gen sumbothallset=sum(bothallsettle)
{txt}
{com}. 
. gen diffdemset=sumfirstdem-sumbothallset
{txt}
{com}. 
. gen violation=1 if firstdem==1 & sumbothallset==0
{txt}(588,685 missing values generated)

{com}. replace violation=0 if violation==. & sumbothallset!=.
{txt}(588,685 real changes made)

{com}. by cdyad: egen maxviolation=max(violation)
{txt}
{com}. 
. tab maxviolation if conttype!=1 & conttype!=.

{txt}maxviolatio {c |}
          n {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}    479,528       81.04       81.04
{txt}          1 {c |}{res}    112,207       18.96      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}    591,735      100.00
{txt}
{com}. tab maxviolation if obs==1 & conttype!=1 & conttype!=.

{txt}maxviolatio {c |}
          n {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     15,886       83.89       83.89
{txt}          1 {c |}{res}      3,050       16.11      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     18,936      100.00
{txt}
{com}. 
. gen simuldyad=1 if sumbothallset==1 & firstdem==1
{txt}(591,309 missing values generated)

{com}. replace simuldyad=0 if simuldyad==. & sumbothallset!=.
{txt}(591,309 real changes made)

{com}. by cdyad: egen maxsimul=max(simuldyad)
{txt}
{com}. 
. tab maxsimul if conttype!=1 & conttype!=.

   {txt}maxsimul {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}    574,877       97.15       97.15
{txt}          1 {c |}{res}     16,858        2.85      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}    591,735      100.00
{txt}
{com}. tab maxsimul if obs==1 & conttype!=1 & conttype!=.

   {txt}maxsimul {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     18,510       97.75       97.75
{txt}          1 {c |}{res}        426        2.25      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     18,936      100.00
{txt}
{com}. 
. by cdyad: egen maxsumfirstdem=max(sumfirstdem)
{txt}
{com}. by cdyad: egen maxsumbothallset=max(sumbothallset)
{txt}
{com}. by cdyad: gen neither=1 if maxsumfirstdem==0 & maxsumbothallset==0
{txt}(368,487 missing values generated)

{com}. by cdyad: replace neither=0 if neither==. & sumbothallset!=.
{txt}(368,487 real changes made)

{com}. 
. tab neither if conttype!=1 & conttype!=.

    {txt}neither {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}    368,487       62.27       62.27
{txt}          1 {c |}{res}    223,248       37.73      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}    591,735      100.00
{txt}
{com}. tab neither if obs==1 & conttype!=1 & conttype!=.

    {txt}neither {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}      9,026       47.67       47.67
{txt}          1 {c |}{res}      9,910       52.33      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     18,936      100.00
{txt}
{com}. 
. gen settlefirst=1 if neither==0 & maxviolation==0 & maxsimul==0
{txt}(352,313 missing values generated)

{com}. replace settlefirst=0 if settlefirst==. & sumbothallset!=.
{txt}(352,313 real changes made)

{com}. 
. tab settlefirst if conttype!=1 & conttype!=.

{txt}settlefirst {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}    352,313       59.54       59.54
{txt}          1 {c |}{res}    239,422       40.46      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}    591,735      100.00
{txt}
{com}. tab settlefirst if obs==1 & conttype!=1 & conttype!=.

{txt}settlefirst {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     13,386       70.69       70.69
{txt}          1 {c |}{res}      5,550       29.31      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     18,936      100.00
{txt}
{com}. 
. *For table: use only settlefirst and violation (which is joint dem first)
. *Dyad= 5550/(5550+3050)=64.53%
. *Dyad-year= 239422/(239422+112207)=68.09%
. 
. 
. *Timing in contiguous, mixed dyads
. use "Owsiak Vasquez - 2016 - Cart and Horse - Replication Data.dta", replace
{txt}
{com}. 
. sort cdyad year
{txt}
{com}. drop if conttype!=1
{txt}(655,227 observations deleted)

{com}. gen mixed=1 if dem1>5 & dem1!=. & dem2<6 & dem2!=.
{txt}(17,121 missing values generated)

{com}. replace mixed=1 if dem1<6 & dem1!=. & dem2>5 & dem2!=.
{txt}(1,390 real changes made)

{com}. replace mixed=0 if mixed==.
{txt}(15,731 real changes made)

{com}. sort cdyad year
{txt}
{com}. 
. gen cdem1=1 if dem1>5 & dem1!=.
{txt}(14,586 missing values generated)

{com}. replace cdem1=0 if cdem1==. & dem1!=.
{txt}(12,811 real changes made)

{com}. 
. gen cdem2=1 if dem2>5 & dem2!=.
{txt}(15,135 missing values generated)

{com}. replace cdem2=0 if cdem2==. & dem2!=.
{txt}(13,360 real changes made)

{com}. 
. by cdyad: gen sumdem1=sum(cdem1)
{txt}
{com}. by cdyad: gen sumdem2=sum(cdem2)
{txt}
{com}. by cdyad: gen obs=_n
{txt}
{com}. by cdyad: gen firstdem1=1 if obs==1 & sumdem1==1
{txt}(19,090 missing values generated)

{com}. by cdyad: replace firstdem1=1 if sumdem1==1 & sumdem1[_n-1]==0
{txt}(123 real changes made)

{com}. by cdyad: replace firstdem1=0 if firstdem1==. & sumdem1!=.
{txt}(18,967 real changes made)

{com}. 
. by cdyad: gen firstdem2=1 if obs==1 & sumdem2==1
{txt}(19,083 missing values generated)

{com}. by cdyad: replace firstdem2=1 if sumdem2==1 & sumdem2[_n-1]==0
{txt}(110 real changes made)

{com}. by cdyad: replace firstdem2=0 if firstdem2==. & sumdem2!=.
{txt}(18,973 real changes made)

{com}. 
. by cdyad: gen firstdemall= firstdem1+firstdem2
{txt}
{com}. by cdyad: replace firstdemall=1 if firstdemall>1
{txt}(37 real changes made)

{com}. *by cdyad: gen firstdemall=firstdem1
. *by cdyad: replace firstdemall=1 if firstdem2==1 & firstdem1==0
. by cdyad: gen runsumdem=sum(firstdemall)
{txt}
{com}. 
. sort cdyad year
{txt}
{com}. by cdyad: gen runsumsettle=sum(settlem) if conttype==1
{txt}
{com}. by cdyad: gen cdiffsumset=runsumdem-runsumsettle
{txt}
{com}. 
. by cdyad: gen cviolation=1 if firstdemall==1 & runsumdem==1 & runsumsettle==0
{txt}(19,077 missing values generated)

{com}. by cdyad: replace cviolation=0 if cviolation==. & runsumsettle!=.
{txt}(19,077 real changes made)

{com}. by cdyad: egen cmaxviolation=max(cviolation)
{txt}
{com}. 
. tab cmaxviolation if conttype==1

{txt}cmaxviolati {c |}
         on {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     14,811       77.29       77.29
{txt}          1 {c |}{res}      4,353       22.71      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     19,164      100.00
{txt}
{com}. tab cmaxviolation if obs==1 & conttype==1

{txt}cmaxviolati {c |}
         on {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}        311       78.14       78.14
{txt}          1 {c |}{res}         87       21.86      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        398      100.00
{txt}
{com}. 
. by cdyad: gen csimuldyad=1 if firstdemall==1 & runsumsettle==1
{txt}(19,092 missing values generated)

{com}. by cdyad: replace csimuldyad=0 if csimuldyad==. & runsumsettle!=.
{txt}(19,092 real changes made)

{com}. by cdyad: egen cmaxsimul=max(csimuldyad)
{txt}
{com}. 
. tab cmaxsimul if conttype==1

  {txt}cmaxsimul {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     16,651       86.89       86.89
{txt}          1 {c |}{res}      2,513       13.11      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     19,164      100.00
{txt}
{com}. tab cmaxsimul if obs==1 & conttype==1

  {txt}cmaxsimul {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}        326       81.91       81.91
{txt}          1 {c |}{res}         72       18.09      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        398      100.00
{txt}
{com}. replace cmaxsim=0 if cdyad==551565
{txt}(12 real changes made)

{com}. 
. by cdyad: egen cmaxrunsumdem=max(runsumdem)
{txt}
{com}. by cdyad: egen cmaxsumsettle=max(runsumsettle)
{txt}
{com}. by cdyad: gen cneither=1 if cmaxrunsumdem==0 & cmaxsumsettle==0 & conttype==1 
{txt}(17,175 missing values generated)

{com}. by cdyad: replace cneither=0 if cneither==. & cmaxsumsettle!=.
{txt}(17,175 real changes made)

{com}. 
. tab cneither if conttype==1

   {txt}cneither {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}     17,175       89.62       89.62
{txt}          1 {c |}{res}      1,989       10.38      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     19,164      100.00
{txt}
{com}. tab cneither if obs==1 & conttype==1

   {txt}cneither {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}        331       83.17       83.17
{txt}          1 {c |}{res}         67       16.83      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        398      100.00
{txt}
{com}. 
. by cdyad: gen csettlefirst=1 if cneither==0 & cmaxviol==0 & cmaxsimul==0
{txt}(8,843 missing values generated)

{com}. by cdyad: replace csettlefirst=0 if csettlefirst==. & cneither!=. & cmaxviol!=. & cmaxsim!=.
{txt}(8,843 real changes made)

{com}. 
. tab csettlefirst if conttype==1

{txt}csettlefirs {c |}
          t {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}      8,843       46.14       46.14
{txt}          1 {c |}{res}     10,321       53.86      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}     19,164      100.00
{txt}
{com}. tab csettlefirst if obs==1 & conttype==1

{txt}csettlefirs {c |}
          t {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}        225       56.53       56.53
{txt}          1 {c |}{res}        173       43.47      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}        398      100.00
{txt}
{com}. 
. *For table: use only settlefirst and violation (which is joint dem first)
. *Dyad= 173/(173+87)=66.54%
. *Dyad-year= 10321/(10321+4353)=70.34%
. 
. *log close
. 
. 
{txt}end of do-file

{com}. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}/Users/Owsiak/Dropbox/Joint Dems and Borders (with JV)/BJPS RR/Replication Files/Replication - Owsiak Vasquez - 2016 - BJPS - Cart and Horse.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}25 Jul 2016, 14:58:11
{txt}{.-}
{smcl}
{txt}{sf}{ul off}